package ${controller_package_name};



import ${request_package_name}.${table_name}Request;
import ${request_package_name}.${table_name}PageRequest;
import ${response_package_name}.${table_name}Response;
import ${service_interface_package_name}.${table_name}Service;
import lombok.extern.slf4j.Slf4j;
import com.doubo.common.model.CommonPageResult;
import com.doubo.common.model.response.CommonResponse;
import com.sibu.shop.admin.web.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
* 描述：${table_annotation}控制层
* @author ${author}
* @date ${date}
*/
@Slf4j
@RestController
@RequestMapping(value = "/${table_name?uncap_first}", produces = MediaType.APPLICATION_JSON_VALUE)
public class ${table_name}Controller {

    @Autowired
    private ${table_name}Service ${table_name?uncap_first}Service;

    /**
    * 描述：保存
    */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public CommonResponse<Boolean> insert${table_name}(@Valid ${table_name}Request request) {
    <#if (content_shop_id)>
        request.setShopId(SessionUtil.getShopId());
    </#if>
        return ${table_name?uncap_first}Service.saveByRequest(request);
    }


    /**
    * 描述：删除
    */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public CommonResponse<Boolean> delete${table_name}(@Valid ${table_name}Request request) {
        <#if (content_shop_id)>
        request.setShopId(SessionUtil.getShopId());
    </#if>
        return ${table_name?uncap_first}Service.deleteByRequest(request);
    }

    /**
    * 描述：详细查询
    */
    @RequestMapping(value = "/detail", method = RequestMethod.POST)
    public CommonResponse<${table_name}Response> detail${table_name}(@Valid ${table_name}Request request) {
    <#if (content_shop_id)>
        request.setShopId(SessionUtil.getShopId());
    </#if>
        return ${table_name?uncap_first}Service.selectDetail(request);
    }

    /**
    * 描述：列表查询
    */
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public CommonResponse<CommonPageResult<${table_name}Response>> listPage${table_name}(@Valid ${table_name}PageRequest request) {
    <#if (content_shop_id)>
        request.setShopId(SessionUtil.getShopId());
    </#if>
        return ${table_name?uncap_first}Service.listForPage(request);
    }


    /**
    * 描述：查询全部
    */
    @RequestMapping(value = "/listAll", method = RequestMethod.POST)
    public CommonResponse<List<${table_name}Response>> listAll${table_name}(@Valid ${table_name}Request request) {
        <#if (content_shop_id)>
        request.setShopId(SessionUtil.getShopId());
        </#if>
        return ${table_name?uncap_first}Service.listAll(request);
    }
}